﻿using Common.Extension;
using Common.Security;

namespace DesignModeConsole.OOPAndPOP.AuthSample
{
    public class AuthService : IService
    {
        public void Main()
        {
            var url = "http://baidu.com";
            var appid = "123456";
            var password = "654321";
            var timestamp = DateTime.Now.GetTimestamp(true); //秒时间戳

            //客户端将信息进行拼接然后生成md5加密
            var token = string.Concat(url + "&" + appid + "&" + password + "&" + timestamp).GetMd5Hash();
            //客户端将上面内容加密然后生成新url，然后拿着url来解析校验

            //生成的新token
            var newUrl = url + "&" + appid + "&" + timestamp + "&" + token;

            var authencator = new DefaultApiAuthencatorImpl();
            authencator.Auth(newUrl);
        }
    }
}